﻿using System;
using System.IO;
using System.Reflection;

namespace CoreLibrary {

    public class Assemblys {

        public static Stream GetStream(string assembly, string path) {
            return GetStream(Assembly.Load(assembly), path);
        }

        public static Stream GetStream(Type type, string path) {
            return GetStream(type.Assembly, path);
        }

        public static Stream GetStream(Assembly assembly, string path) {
            var resource = assembly.GetManifestResourceStream(assembly.GetName().Name + '.' + path);
            return resource;
        }

        public static string GetString(string assembly, string path) {
            return IOUtil.ReadStringAndClose(GetStream(assembly, path));
        }

        public static string GetString(Type type, string path) {
            return IOUtil.ReadStringAndClose(GetStream(type, path));
        }

        public static string GetString(Assembly assembly, string path) {
            return IOUtil.ReadStringAndClose(GetStream(assembly, path));
        }

    }
}
